package util;

import lombok.Data;

/**
 * @classname:ServerResponseResult
 * @description:
 * @author: Mr.Z
 * @date: 2020/12/30 9:02
 * @version: 0.1
 * @since:1.8
 */
@Data
public class ServerResponseResult<D> {
    private String message;
    private Integer status;
    private D data;


    public static <D> ServerResponseResult<D> success(D data) {
        return new ServerResponseResult<>(CodeEnum.SUCCESS.getMsg(), CodeEnum.SUCCESS.getCode(), data);
    }
    public static <D> ServerResponseResult<D> success(String msg, D data) {
        return new ServerResponseResult<>(msg, CodeEnum.SUCCESS.getCode(), data);
    }

    public static <D> ServerResponseResult<D> success() {
        return new ServerResponseResult<>(CodeEnum.SUCCESS.getMsg(), CodeEnum.SUCCESS.getCode());
    }

    public static <D> ServerResponseResult<D> error(){
        return new ServerResponseResult<>(CodeEnum.ERROR.getMsg(),CodeEnum.ERROR.getCode());
    }

    public ServerResponseResult(String message, Integer status, D data) {
        this.message = message;
        this.status = status;
        this.data = data;
    }

    public ServerResponseResult(String message, Integer status) {
        this.message = message;
        this.status = status;
    }
    public ServerResponseResult() {
    }

}
